home *** CD-ROM | disk | FTP | other *** search
/ ftp.cs.arizona.edu / ftp.cs.arizona.edu.tar / ftp.cs.arizona.edu / icon / newsgrp / group97b.txt / 000122_icon-group-sender _Fri Nov 14 10:46:45 1997.msg < prev    next >
Internet Message Format  |  2000-09-20  |  2KB

  1. Return-Path: <icon-group-sender>
  2. Received: from kingfisher.CS.Arizona.EDU (kingfisher.CS.Arizona.EDU [192.12.69.239])
  3.     by baskerville.CS.Arizona.EDU (8.8.7/8.8.7) with SMTP id KAA10976
  4.     for <icon-group-addresses@baskerville.CS.Arizona.EDU>; Fri, 14 Nov 1997 10:46:45 -0700 (MST)
  5. Received: by kingfisher.CS.Arizona.EDU (5.65v4.0/1.1.8.2/08Nov94-0446PM)
  6.     id AA09772; Fri, 14 Nov 1997 10:46:44 -0700
  7. To: icon-group@optima.CS.Arizona.EDU
  8. Date: 13 Nov 1997 13:08:13 GMT
  9. From: eddie@holyrood.ed.ac.uk (Eddie Corns)
  10. Message-Id: <64eu3t$c7l@scotsman.ed.ac.uk>
  11. Organization: Edinburgh University
  12. Sender: icon-group-request@optima.CS.Arizona.EDU
  13. References: <Pine.LNX.3.95.971110105527.10736A-100000@uther.cs.engr.uky.edu>
  14. Subject: Re: Regular Expressions (+ description of useful prog)
  15. Errors-To: icon-group-errors@optima.CS.Arizona.EDU
  16. Status: RO
  17.  
  18. Chris Lusena <lusena@cs.uky.edu> writes:
  19.  
  20.  
  21. >For part of a class project I need/like to be able to find all
  22. >occanses of a Regular Expression in a ASCII file. Icon seams that is might
  23. >be good for this, since one can fine all occurance of a word easly.
  24.  
  25. >So how would one go about this? I'd like to be able to serach for the Reg.  
  26. >Exp. over line breaks if possable.
  27.  
  28.  
  29. It's not clear whether you're looking to write a program or maybe you're just
  30. saddled with a deficient machine that doesn't have the grep program.  Or
  31. perhaps you're not aware that regular expression matching is an order of
  32. magnitude or two more complex than a straightforward search!  There is
  33. certainly a regular expression library in the icon library (regexp.icn).
  34.  
  35. However, to make it work across lines you'd need to read the entire file into
  36. a string then call ReFind().  Using the default pattern matching rule of
  37. leftmost longest match however this can be excrutiatingly slow.  Regexp.icn
  38. does have a way of doing shortest first which speeds things up considerably
  39. and would probably be essential.
  40.  
  41. As an alternative you (and others reading this group) may want to look at a
  42. program called cgrep which I came across some time ago.  Look at
  43. ftp://plg.uwaterloo.ca/pub/mt/cgrep for details.  There is a report.ps which
  44. describes the problems fairly well and a c program which ought to compile on
  45. most platforms.  This program does shortest first matching as well as allowing
  46. you to define boundary conditions (using regular expressions) which makes
  47. searching structured files a breeze.
  48.  
  49. Eddie
  50.